package edu.ucsur.libreria.servlet;



import java.io.IOException;
import java.sql.ResultSetMetaData;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import edu.ucsur.ventasweb.BusinessEntity.ENVenta;
import edu.ucsur.ventasweb.BusinessLogic.*;


/**
 * Servlet implementation class ConsultaProductoServlet
 */
@WebServlet("/ConsultaProductoServlet")
public class ConsultaVentaServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ConsultaVentaServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		  try 
		  {
			  List<ENVenta> lista = LNVenta.Instance().Listar();	  
			  
			  //Guardar en una variable de request
			  request.setAttribute("listaJSP", lista);
			  //Invocar al JSP que muestra el listado
			  RequestDispatcher dispatcher = request.getRequestDispatcher("/FormConsultaVenta.jsp");
			  dispatcher.forward(request, response);
	  	    

		  }
		  catch (Exception ex) 
		  {
		    ex.printStackTrace();
		  }
		}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
	}

}
